package com.capgemini.diabeo.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.capgemini.diabeo.manager.SearchManager;
import com.capgemini.diabeo.model.Menu;
import com.capgemini.diabeo.view.MenuItemView;
import com.capgemini.diabeo.view.MenuItemView_;
import com.googlecode.androidannotations.annotations.AfterInject;
import com.googlecode.androidannotations.annotations.EBean;
import com.googlecode.androidannotations.annotations.RootContext;

@EBean
public class MenuListAdapter extends BaseAdapter {

	private List<Menu> menus;
	private SearchManager searchManager;
	
	@RootContext
	static Context context;
	
	

	private boolean hasAddButton = true;

	@AfterInject
	public void afterInject() {
		menus = new ArrayList<Menu>();
	}

	public void setMenuList(List<Menu> menus) {
		this.menus = menus;
	}
	public List<Menu> getMenuList() {
		return this.menus ;
	}
	public void setManager(SearchManager manager){
		this.searchManager = manager;
	}


	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		MenuItemView menuItemView;
		if (convertView == null) {
			
			menuItemView = MenuItemView_.build(context);
		} else {
			menuItemView = (MenuItemView) convertView;
		}
//		menuItemView.setManager(searchManager);
		menuItemView.bind(getItem(position));

		return menuItemView;
	}

	@Override
	public int getCount() {
		return menus.size();
	}

	@Override
	public Menu getItem(int position) {
		return menus.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}
}